import { Element } from 'diagram-js/lib/model/Types';
import { is, getBusinessObject } from 'bpmn-js/lib/util/ModelUtil';
import modelerStore from '@wf/components/bpmnjs/store/modeler';
import { cloneDeep } from 'lodash-es';

export function isGateway(element: Element) {
  return element.type.includes('Gateway');
}

// 获取指定网关节所有outgoing
export function getGatewayOutgoing(element: Element) {
//   const businessObject = getBusinessObject(element);
  const outgoing = element.outgoing;
  if (!outgoing) return [];
  return outgoing;
}

// 对指定项的outgoing进行上移
export function moveGatewayOutgoingUp(outgoing: Element, index: number) {
  const outgoingItem = outgoing[index];
  outgoing.splice(index, 1);
  outgoing.splice(index - 1, 0, outgoingItem);
}

// 对指定项的outgoing进行下移
export function moveGatewayOutgoingDown(outgoing: Element, index: number) {
  const outgoingItem = outgoing[index];
  outgoing.splice(index, 1);
  outgoing.splice(index + 1, 0, outgoingItem);
}
